package com.qiandw.enterprise

import java.util.List

import com.alibaba.fastjson.JSON

/**
  * Created by Draven on 2018/7/10.
  * Email:hjx@qiandw.com
  */
package object credit {

  val SYS_MSG_SUCCESS = (200, "操作成功", "")

  val SYS_MSG_ILLEGAL_ARGUMENT = (99001, "", "参数有误")

  val SYS_MSG_ERROR = (99999, "", "系统错误")

  val SYS_MSG_PWD_ERROR = (99902, "", "用户名或密码错误")

  val SYS_MSG_VERIFYCODE_ERROR = (99903, "", "验证码错误")

  val SYS_SESSION_TIME_OUT = (99904, "", "登录超时")

  val SESSION_USER_KEY = "QVbjRuq9NYQ7mjT"

  def listToJsonStrWithTotalCount[T](data: List[T]): String = {
    var json = ""
    if (!data.isEmpty) {
      val dataJsonStr = JSON.toJSON(data)
      json = "{\"total\":" + data.size() + ",\"rows\":" + dataJsonStr + "}"
    } else {
      json = "{\"total\":0,\"rows\":[]}"
    }
    json
  }
}
